<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="pg" uri="http://jsptags.com/tags/navigation/pager" %>
<%--
  Created by IntelliJ IDEA.
  User: 001
  Date: 2017/6/12
  Time: 19:57
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
  <title></title>
  <style>
    table{border: 1px solid #ccc;border-collapse: collapse; width:80%;}
    table th,table td{border: 1px solid #ccc;padding: 10px;}
  </style>
</head>
<body>
<h2><a href="/user/add">添加用户</a></h2><br>
<table>
  <thead>
  <tr>
    <th>id</th>
    <th>username</th>
    <th>password</th>
    <th>sex</th>
    <th>age</th>
    <th>sdept</th>
    <th>删除</th>
    <th>更新</th>
  </tr>
  </thead>
  <c:forEach items="${users}" var="um">
    <%--um.vlaue得到map值--%>
    <tbody>
    <tr>
      <td> ${um.id}</td>
      <td> ${um.username}</td>
      <td> ${um.password}</td>
      <td> ${um.sex eq 0?"男":"女"}</td>
      <td> ${um.age}</td>
      <td> ${um.sdept}</td>
      <td> <a href="${um.id}/delete" >删除</a></td>
      <td><a href="${um.id}/update?id=${um.id}">更新</a></td>
    </tr>
    </tbody>
  </c:forEach>
</table>

<pg:pager  url="/user/showuserlist" items="1000" maxIndexPages="5" maxPageItems="${pager.pageSize}" export="currentPageNumber=pageNumber"><!-- export对pageNumber的重命名 -->
<pg:first>
  <a href="${pageUrl }">首页</a>
</pg:first>
<pg:prev>
  <a href="${pageUrl }">上一页</a>
</pg:prev>
<pg:pages>
  <c:choose>
    <c:when test="${currentPageNumber eq pageNumber }">
      <font color="red">${pageNumber }</font>
    </c:when>
    <c:otherwise>
      <a href="${pageUrl }">${pageNumber }</a>
    </c:otherwise>
  </c:choose>
</pg:pages>
<pg:next>
  <a href="${pageUrl }">下一页</a>
</pg:next>
<pg:last>
  <a href="${pageUrl }">尾页</a>
</pg:last>
<br/>
当前第${pager.pageIndex}页,共${pager.totalPage}页
</pg:pager>

</body>
</html>
